package com.hushi.impl;

import com.hushi.dao.CustomerDao;
import com.hushi.domain.Customer;
import com.hushi.service.CustomerService;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Properties;

public class CustomerServiceImpl implements CustomerService {
    private CustomerDao customerDao;
    private String name;
    //关键在这里，提供CustomerDao作为参数的构造方法，待会在配置文件进行注入
//    有参构造
    public CustomerServiceImpl(CustomerDao customerDao){
        super();
        this.customerDao=customerDao;
    }

    //    setter方法
    public void setCustomerDao(CustomerDao customerDao) {
        this.customerDao = customerDao;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public void save(){
        customerDao.save();
        System.out.println(name);
    }

//    无参构造
    public CustomerServiceImpl() {
    }

//    普通数据据类型
    private String gender;
    public void setGender(String gender) {
        this.gender = gender;
    }

    //    javaBean类型注入
    private Customer customer;

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    //数组类型
    private String[] addresses;

    public void setAddresses(String[] addresses) {
        this.addresses = addresses;
    }

    //List集合类型
    private List<Customer> customerList;

    public void setCustomerList(List<Customer> customerList) {
        this.customerList = customerList;
    }

    //map集合类型
    private Map<String,Customer> customerMap;

    public void setCustomerMap(Map<String, Customer> customerMap) {
        this.customerMap = customerMap;
    }

//    propertis类型
    private Properties propertiesCustomer;

    public void setPropertiesCustomer(Properties propertiesCustomer) {
        this.propertiesCustomer = propertiesCustomer;
    }

    @Override
    public String toString() {
        return "CustomerServiceImpl{" +
                "customerDao=" + customerDao +"\n"+
                ", name='" + name + '\'' +"\n"+
                ", gender='" + gender + '\'' +"\n"+
                ", customer=" + customer +"\n"+
                ", addresses=" + Arrays.toString(addresses) +"\n"+
                ", customerList=" + customerList +"\n"+
                ", customerMap=" + customerMap +"\n"+
                ", propertiesCustomer=" + propertiesCustomer +
                '}';
    }
}
